import { createStore } from 'vuex'

export default createStore({
  state: {
    totalList: [], //用于最终排序显示
    userList: [], //总用户显示
    msgList: [],  // 消息捕获
    joinRoom: [],  //加入的人
    leaveRoom: ""  //离开的人
  },
  getters: {
    GET_USERLIST: (state) => {
      return state.userList
    },
    GET_MSGLIST: (state) => {
      return state.msgList
    }
  },
  mutations: {
    SET_USERLIST (state, userList) { //推送在线人数
      state.userList = userList
    },
    SET_MSG (state, msg) { //存入历史数据
      state.msgList.push(msg)
    },
    SET_JOINPERSON (state, person) {
      state.joinRoom.push(person)
    },
    SET_LEAVEROOM (state, person) {
      state.leaveRoom = person
    },
    ADD_TOTALlIST (state, objToJudge) {
      state.totalList.push(objToJudge)
    }
  },
  actions: {

  },
  modules: {
  }
})
